package com.nstar.base.container
{
	import mx.containers.HBox;
	import mx.events.FlexEvent;
	import mx.effects.Resize;
	import mx.controls.LinkButton;
	import flash.events.MouseEvent;
	import flash.events.Event;
	
	/**
	 * 隐藏的按钮栏
	 * 
	 * @author 李嘉陵
	 * @date 2007.1
	 */
	public class HiddenBar extends HBox
	{
		private var originWidth:uint;
		private var expand:Resize;
		private var contract:Resize;
		private var btControl:LinkButton;
		
		public function HiddenBar() {
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
			
			btControl = new LinkButton();
			btControl.label = "<<";
			btControl.setStyle("fontSize",6);
			btControl.addEventListener(MouseEvent.CLICK,show);
			this.addChild(btControl);
		}
		
		private function init(event:Event) {
			//originWidth = this.width;
			var children:Array = new Array();
			for(var i=1;i<this.numChildren-1;i++) {
				var child = this.getChildAt(i);
				children.push(child);
			}
			
			expand = new Resize(this);
			expand.widthTo = this.width;
			expand.hideChildrenTargets = children;
			
			contract = new Resize(this);
			contract.widthTo = 30;
			contract.hideChildrenTargets = children;
			
			//初始时隐藏按钮
			this.width = 30;
			
			this.horizontalScrollPolicy = "off";
		}
		
		private function show(event:Event) {
				if(this.width == 30) {
					//showBar.setStyle("resizeEffect",wipeIn);
					expand.end();
					expand.play();
					btControl.label = ">>";
				}
				else {
					//showBar.setStyle("resizeEffect",wipeOut);
					contract.end();
					contract.play();
					btControl.label = "<<";
				}
				
				
				
		}
		
		
	}
}